﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ReviewCurveApp.Classes
{
    public class DbHelper
    {
        static public int? GetIntValueFromRow(string fieldName,DataRow dr)
        {
            if (dr[fieldName]==null)
            {
                return null;
            }

            string value = dr[fieldName].ToString();

            if (string.IsNullOrEmpty(value)) return null;


            return int.Parse(value);

        }

        static public string GetStringFromRow(string fieldName,DataRow dr)
        {
            string value = dr[fieldName].ToString();

            return value;
        }

        static public DateTime? GetDateTimeFromRow(string fieldName,DataRow dr)
        {
            if (dr[fieldName] == null)
            {
                return null;
            }

            string value = dr[fieldName].ToString();

            if (string.IsNullOrEmpty(value)) return null;

            return DateTime.Parse(value);
        }

    }
}
